package com.demo.seckill.mybatis;

import org.apache.ibatis.jdbc.SQL;
import org.springframework.data.repository.query.Param;

/**
 * @author libo
 * @ClassName UserSqlProvider
 * @date 2018/12/28 16:05
 */
public class UserSqlProvider {
    public  String  listByName(String  name){
        return "select * from userinfo where username= #{name}";
    }

    public String getBadUser(@Param("name") String name, @Param("sex") String sex) {
        return new SQL() {{
            SELECT("*");
            FROM("userinfo");
            if (name != null && sex != null) {
                WHERE("username like #{name} and sex like #{sex}");
            } else {
                WHERE("1=2");
            }
        }}.toString();
    }
}
